package com.lagou;

import com.lagou.Thread.Task;
import com.lagou.bean.ConsumerComponent;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author czq
 * @date 2020/9/2 22:57
 */
public class AnnotationConsumerMain {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();

        ConsumerComponent consumerComponent = context.getBean(ConsumerComponent.class);
        ExecutorService executorService = Executors.newFixedThreadPool(3);
        for (int i = 0; i < 2000; i++) {
            executorService.execute(new Task("methodA", consumerComponent));
            executorService.execute(new Task("methodB", consumerComponent));
            executorService.execute(new Task("methodC", consumerComponent));
        }
    }

    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    @ComponentScan("com.lagou.bean")
    @EnableDubbo
    static class ConsumerConfiguration {

    }
}
